<?php
/**
 * Building View for RoomBooking Component
 * 
 * @version    1.0
 * @package    Joomla
 * @subpackage RoomBooking
 * @copyright (C) 2011 Giovanni Marzulli
 * @license	   GNU/GPL
 */
 
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.view' );
 
class RoomBookingViewBuilding extends JView
{
	 /**
     * Bookings view display method
     * @return void
     **/
	function display($tpl = null)
	{
		//get the building
		$item		=& $this->get('Data');
		$model = &$this->getModel();
		$modelOrganizations = &$this->getModel('organizations');
		$organizations = $modelOrganizations->getData();
		$orgs_associate = $model->getOrgsAssociate();
		$isNew		= ($item->id < 1);

		$text = $isNew ? JText::_( 'New' ) : JText::_( 'Edit' );
		JToolBarHelper::title(   JText::_( 'BUILDING' ).': <small><small>[ ' . $text.' ]</small></small>' );
		JToolBarHelper::save();
		JToolBarHelper::apply();
		if ($isNew)  {
			JToolBarHelper::cancel();
		} else {
			// for existing items the button is renamed `close`
			JToolBarHelper::cancel( 'cancel', 'Close' );
		}
		$this->assignRef('item', $item);
		$this->assignRef('organizations', JHTML::_('select.genericlist',$organizations, 'orgs[]', 'class="inputbox" multiple="multiple" style="width:300px"','id','name',$orgs_associate));
		$this->assignRef('we_opening', JHTML::_('select.booleanlist','we_opening', 'class="inputbox"' ,$item->we_opening));
		parent::display($tpl);
	}
}
